package org.etom.impl.ui.wizards;

import org.eclipse.swt.widgets.Composite;
import org.etom.connector.datatypes.IMoodleConnection;

public class NewAccountWizardPage1
              extends AbstractNewAccountWizardPage1 {
  
  private IMoodleConnection moodleConnection;
  
  public NewAccountWizardPage1(IMoodleConnection moodleConnection) {
    this.moodleConnection = moodleConnection;
  }

  @Override
  public void createControl(Composite parent) {
    super.createControl(parent);
    init();
  }

  public String getMoodleUrl() {
    return moodleUrlText.getText();
  }
  
  public String getRpcServerUrl() {
    return rpcServerUrlText.getText();
  }
  
  public String getUsername() {
    return usernameText.getText();
  }
  
  public String getPassword() {
    return passwordText.getText();
  }
  
  public boolean validateOnFinish(){
    return validateOnFinish.getSelection();
  }
  
  private void init() {
    //if true, we have create operation
    if (null == moodleConnection) return;
    //if false, we have edit operation
    moodleUrlText.setText(moodleConnection.getMoodleUrl());
    rpcServerUrlText.setText(moodleConnection.getRpcServerUrl());
    usernameText.setText(moodleConnection.getUserName());
    passwordText.setText(moodleConnection.getPassword());
  }
  
}
